﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class admin_Default : System.Web.UI.Page
{
    ProductBus productBus = new ProductBus();
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //    GridView1.Visible = true;
        //else { GridView1.Visible = true; }
    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        //String selectCommand = "SELECT * FROM [Products] ";
        //SqlDataAdapter ad = new SqlDataAdapter(selectCommand, SqlDataSource1.ConnectionString);

        //DataTable dt = new DataTable();
        //ad.Fill(dt);
        //GridView1.DataSource = dt;
        
        //GridView1.DataBind();
        //GridView1.Visible = true;

        DataTable dt = productBus.GetUrlImgByCategoryName("Tank");
        listView1.DataSource = dt;
        listView1.DataBind();
    }

    public void phepcong(int a, int b) {
        int c = a + b;
    }
    public void sudung()
    {
        phepcong(3, 50);
    }
    public List<Product> GetProductDetail(string productid, DataTable dt)
    {
        List<Product> list = new List<Product>();
        
      

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            Product product = new Product();
            product.ProductId = productBus.GetProductDetailsByNameandId(productid, dt.Rows[i]["ProfuctId"].ToString());
            //product.Quantity = int.Parse(dt.Rows[i]["Quantity"].ToString());
            list.Add(product);
        }

        return list;
        
    }
    //protected void LinkButton1_Click(object sender, EventArgs e)
    //{
       
    //        Session["productedit"] = new List<Product>();

       
      
    //        DataTable dt = new DataTable();
           


    //        Put product detail to session

    //        dt = productBus.GetProductDetailById(e.);

    //        Session["productedit"] = productBus.GetProductDetailsByNameandId(dt);

    //        ListBox1.Items.Clear();

    //        for (int i = 0; i < dt.Rows.Count; i++)
    //        {
    //            ListBox1.Items.Add(dt.Rows[i]["ProductId"].ToString() + " - " + dt.Rows[i]["ProductName"].ToString());
    //        }

    //        if (dt.Rows.Count != 0)
    //        {
              

    //            txtId.Text = dt.Rows[0]["ProductId"].ToString();
    //            txtName.Text = dt.Rows[0]["ProductName"].ToString();
    //            txtCategoryId.Text = dt.Rows[0]["CategoryId"].ToString();
    //            txtSize.Text = string.Format("{0:0}", dt.Rows[0]["Size"].ToString());
    //            txtColor.Text = dt.Rows[0]["Color"].ToString();
    //            txtPrice.Text = string.Format("{0:0,0.0}", dt.Rows[0]["Price"].ToString());
    //            txtImage.Text = dt.Rows[0]["Image"].ToString();


    //        }

    //    }
        }
    
